package org.example.encoding;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Yyming
 * @version 10.0
 * Created by Yyming on 2021/2/19
 */
public class Encode {
    private static final Pattern P = Pattern.compile("-?\\d+");
    public static void main(String[] args) throws UnsupportedEncodingException {
//        String s = "日期";
//        System.out.println(new String(s.getBytes("GBK"),StandardCharsets.ISO_8859_1));
        String str = "错误代码:11300001 数据集配置错误\n" +
                "Query:\n" +
                "wait millis 1003, active 0, maxActive 50";
        long start = System.nanoTime();
//        Matcher matcher = P.matcher(str);
//        if (matcher.find()) {
//            System.out.println(matcher.group());
//        }
        StringBuilder re = new StringBuilder();
        boolean f = false;
        for (char c : str.toCharArray()) {
            if (Character.isDigit(c)) {
                f = true;
                re.append(c);
                continue;
            }
            if (f) {
                break;
            }
        }
        System.out.println(re.toString());
        System.out.println(System.nanoTime() - start);
    }
}
